
package com.be.beadmin.project.repository;

import com.be.beadmin.project.entity.Team;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author zjm
* @date 2023-02-06
**/
public interface TeamRepository extends JpaRepository<Team, String>, JpaSpecificationExecutor<Team> {

    Team findTeamByIdAndDelete(String id, Integer delete);


//    List<Team> findTeamByIdInAndDelete(String id, Integer delete);
//    List<Team> findTeamByTeamNameAndInfoIdAndDelete(String teamName, String infoId, Integer delete);

//    Team findTeamByTeamNameAndDelete(String teamName, Integer delete);

    List<Team> findTeamByTeamNameAndDelete(String teamName,  Integer delete);

//    List<Team> findTeamByInfoIdAndDelete(String infoId, Integer delete);

    List<Team> findAllByDelete(Integer delete);


    List<Team> findAllByStateAndDelete(Integer state, Integer delete);
    Team findTeamById(String id);

    @Modifying
    @Transactional
    @Query(value = "update t_pm_team t set t.is_delete = ?1 where t.info_id = ?2 and t.is_delete = ?3",nativeQuery = true)
    void deleteTeamByInfoIdAndDelete(int deleted,String infoId,int nodelete);

}